﻿/** 异形对铁血战士

  By setycyas @2023-03-05
*/

/* 全局设定
*/ {
#Include "..\Class\MyFuns.2.ahk"
#Include "..\Class\OrderMap.2.ahk"
#Include "..\Class\MyEmu.2.ahk"
#Include "..\Class\FaceDetector.2.ahk"
#Include "..\Class\CommonMacro.2.ahk"
#Include "..\Class\CommonUI.2.ahk"

#Warn
#MaxThreadsPerHotkey 1

SetWorkingDir(A_ScriptDir)
SendMode("Event")
;SendMode("Input")
}

/* 制作异形对铁血战士的宏类
*/ class AvspMacro extends CommonMacro {

  pressDuration := 30

  /* 新增的宏函数
  */
  _下上拳(key){
    send("{down down}")
	  sleep(30)
	  send("{down up}")
	  sleep(30)
	  send("{up down}")
	  sleep(30)
	  this._down(2)
	  sleep(30)
	  send("{up up}")
	  this._up(2)
  }
  _滑铲(key){
    local face := this._face.face()
    MyFuns.pressKeys([face, "down", this._keys[3]], [50, 50, 150])
    sleep(200)
  }
  _大跳(key){
    local face := this._face.face()
    MyFuns.pressKeys([face, "up", this._keys[3]], [50, 50, 150])
    sleep(200)
  }
  _后跳(key){
    local back := this._face.back()
    MyFuns.pressKeys([this._keys[3], back], [20, 40])
    Sleep(30)
    this._press(2)
  }
  _快速旋转拳(key){
    static delays := [20, 20, 20, 20, 20]
    local thisKey := MyFuns.getHotkey(key) ;触发技能的热键
    local keys := ["up", "right", "down", "left", this._keys[2]]
    while (GetKeyState(thisKey, "P")) {
      MyFuns.inputSkill(keys, delays)
    }
  }
  _连发保险(key){
    local thisKey := MyFuns.getHotkey(key) ;触发技能的热键
    loop {
      this._press(4)
      sleep(50)
      if (!GetKeyState(thisKey, "P")){
        break
      }
    }
  }

  /* 重载宏接口
  */
  _setMacro(){
    this.macroMap := OrderMap()
    this.macroMap["下上拳"] := this._下上拳.bind(this)
    this.macroMap["大跳"] := this._大跳.bind(this)
    this.macroMap["滑铲"] := this._滑铲.bind(this)
    this.macroMap["后跳"] := this._后跳.bind(this)
    this.macroMap["快速旋转拳"] := this._快速旋转拳.bind(this)
    this.macroMap["连发保险"] := ObjBindMethod(this, "_连发保险")
    this.macroArr := this.macroMap.getKeys()
  }
}

/* 运行当前脚本
*/ if (A_ScriptName == "异形对铁血战士.2.ahk") {
  face := FaceDetector() ;方向检测对象
  macro := AvspMacro(face, ["q","f"]) ;宏对象,有界面时第二个参数可以随便写但长度不要小于2
  ;宏方案预设,用于菜单
  preset := OrderMap(["默认", ["下上拳", "大跳", "滑铲", "后跳", "快速旋转拳", "连发保险"]])
  ;新建界面对象并显示
  ui := CommonUI("异形对铁血战士", macro, preset)
  ui.setup()
  ;更新组件内容
  ui._exeComboBox.Choose(MyEmu.NEBULA)
  ui._gameKeyEdit.Text := "c,e,f,p" ;最后一个按键是保险热键
  ui._hotkeyEdit.Text := "s,r,g,x,v,space"
  ui._fpsEdit.Text := 15
  ui._testEdit.Text := "50,50,150"
  ui.readPresetMenu("默认")
}
